<?php
define('PEXI_ROOT_DIR', dirname(dirname(__FILE__)));
set_include_path(
    get_include_path() . PATH_SEPARATOR .
    PEXI_ROOT_DIR . '/lib' . PATH_SEPARATOR .
    PEXI_ROOT_DIR . '/application/models'
);


/* Autoloader */
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();


/* Session */
Zend_Session::start();


/* Config */
$cfg = new Zend_Config_Ini(PEXI_ROOT_DIR . '/application/config/config.ini', 'development', array('allowModifications' => true));
Zend_Registry::set('cfg', $cfg);


/* Locale, Error Handling */
setlocale (LC_ALL, 'de_DE.UTF8', 'de_DE', 'de', 'ge');
ini_set('default_mimetype', 'text/html');
ini_set('default_charset', 'utf-8');
ini_set('error_reporting', $cfg->ini->error_reporting);
ini_set('display_errors', $cfg->ini->display_errors);
ini_set('display_startup_errors', $cfg->ini->display_startup_errors);
ini_set('log_errors', $cfg->ini->log_errors);
ini_set('log_errors_max_len', $cfg->ini->log_errors_max_len);
ini_set('report_memleaks', $cfg->ini->report_memleaks);
ini_set('html_errors', $cfg->ini->html_errors);


/* Db */
$dbConfig = $cfg->db->toArray();
$dbConfig['driver_options'][PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'utf8'";
$db = Zend_Db::factory($cfg->db->adapter, $dbConfig);
Zend_Registry::set('db', $db);

//unset($cfg, $db, $mvc, $view, $viewRenderer, $auth, $acl, $request, $router, $controller);